import TWEEN from "@tweenjs/tween.js";

export function CreateAniNum(newValue, oldValue,content,key) {
  function animate() {
    if (TWEEN.update()) {
      requestAnimationFrame(animate)
    }
  }
  new TWEEN.Tween({tweeningNumber: oldValue})
    .easing(TWEEN.Easing.Quadratic.Out)
    .to({tweeningNumber: newValue}, 800)
    .onUpdate(function () {
      content[key] = this._object.tweeningNumber.toFixed(0)
    })
    .start();
  animate();
}
